<form>
<div class="x-list-title">
<table width="100%" border="0" height="100%">
	<tr>
		<td align="left">
			<h2>Lịch cá nhân ngày</h2>
		</td>
		<td align="right">	
			<div class="x-list-options">	
				<a href="#Calendar/Index/Add" class="x-button">Lịch cá nhân mới</a>
				<a href="#Calendar/Company/Add" class="x-button">Lịch cơ quan mới</a>
			</div>
		</td>
	</tr>
</table>	
</div>
<div class="calendar-bar-container">
	<div class="calendar-bar">
		<?php $time = $this->get('time');?>
		<?php $pre_date  = date("Y-m-d",strtotime("-1 day",$time));?>
		<?php $next_date = date("Y-m-d",strtotime("+1 day",$time));?>
		<div class="calendar-ctr"><a href="#Calendar?date=<?php _e($pre_date);?>" class="pre-calendar"></a>
		<a href="#Calendar?date=<?php _e($next_date);?>" class="next-calendar"></a></div>
		  <?php _e(vn_day($time))?> ngày <?php _e(date("d",$time))?> tháng <?php _e(date("m",$time))?> năm <?php _e(date("Y",$time))?>
		<?php include "_Options.phtml";?>  
	</div>
</div>
<?php $posts = $this->get('posts');?>
<table width="100%" class="x-list" cellpadding="0" cellspacing="0">
<?php $now = date('d/m/Y',$time) == date('d/m/Y');?>	
<?php for( $i=0; $i <= 23 ; $i++ ):?>
	<?php $html = "";?>
	<?php foreach( $posts as $k => $a ):?>
	<?php $time_start = strtotime($a['time_start']);
		$time_end = strtotime($a['time_end']);
		$time_now = strtotime("$i:00:00");
				
		$is_current = $now && (((int)date("H")) >= $i ) && (((int)date("H")) < $i+1 )
			? " class='time-current'" :'';
		
		if( $time_start >= $time_now && strtotime(($i+1).":00:00") > $time_start ):?>
		<?php
			$time = date('H:i',strtotime($a['time_start']))." - ".date('H:i',strtotime($a['time_end']));
			
			$html .="<div class='calendar-post'>
				<a class='x-tooltip' href='#Calendar/Index/View?ID={$a['ID']}'>&#187; {$a['title']}
				<div class='x-toolbox'>
					<div class='event-quick-box'>
					<div style='border-bottom:1px solid #ddd;padding:0px 0px 5px 0px'>
					<big><b>{$a['title']}</b></big><br/>
					<i>$time</i><br/>
					</div><div style='padding:5px 0px'>
					".short_title(strip_tags($a['content']),300)."
					</div></div>
				</div>
				</a> ( $time )
			</div>";			
		?>
	<?php endif;?>
	<?php endforeach;?>
	<?php if( $i < 6 ):?>	
	<tr class="cday-outtime<?php _e($html ? "":" cday-hide");?>">
		<td align="center" width="100">
			<span<?php _e($is_current)?>><?php _e(date("H:i",strtotime("$i:00:00")));?></span>
		</td>
		<td valign="top">
		<?php _e($html);?>	
		</td>
	</tr>
	<?php endif;?>
	<?php if( $i <= 18 && $i >= 6 ):?>	
	<tr class="cday-intime">
		<td align="center" width="100">
			<span<?php _e($is_current)?>><?php _e(date("H:i",strtotime("$i:00:00")));?></span>
		</td>
		<td valign="top">
		<?php _e($html);?>
		</td>
	</tr>
	<?php endif;?>
	<?php if( $i > 18 ):?>	
	<tr class="cday-outtime<?php _e($html ? "":" cday-hide");?>">
		<td align="center" width="100">
			<span<?php _e($is_current)?>><?php _e(date("H:i",strtotime("$i:00:00")));?></span>
		</td>
		<td valign="top">
		<?php _e($html);?>
		</td>
	</tr>
	<?php endif;?>
<?php endfor;?>
</table>
<div align="right" class="calendar-expand">
	<a onclick="calendar_expand_day(this)" >[mở rộng]</a>
</div>